<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('收支记录列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>物品名称：</label>
                                <input type="text" name="produceName"/>
                            </li>
                            <li>
                                <label>支付种类：</label>
                                <select name="playType" th:with="type=${@dict.getType('biz_incomePlayInfo_playType')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>物品种类：</label>
                                <select name="produceType" th:with="type=${@dict.getType('biz_incomePlayInfo_produceType')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>物品价格：</label>
                                <input type="text" name="producePrice"/>
                            </li>
                            <li class="select-time">
                                <label>交易时间：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginProducePalydate]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endProducePalydate]"/>
                            </li>
                            <li>
                                <label>物品描述：</label>
                                <input type="text" name="produceDesc"/>
                            </li>
                            <li>
                                <label>交易人：</label>
                                <select name="produceNegotiator" th:with="type=${@dict.getType('biz_incomePlayInfo_negotiator')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="total()"><i class="fa fa-refresh"></i>&nbsp;统计</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:incomeplayinfo:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:incomeplayinfo:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:incomeplayinfo:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:incomeplayinfo:export">
                    <i class="fa fa-download"></i> 导出
                </a>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <i></i>收入: <label id="income" th:text="${incomeStr}"></label>元;支出: <label id="play" th:text="${playStr}"></label>元;余额: <label id="balance" th:text="${balanceStr}"></label>元
            </div>
            
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:incomeplayinfo:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:incomeplayinfo:remove')}]];
        var playTypeDatas = [[${@dict.getType('biz_incomePlayInfo_playType')}]];
        var produceTypeDatas = [[${@dict.getType('biz_incomePlayInfo_produceType')}]];
        var produceNegotiatorDatas = [[${@dict.getType('biz_incomePlayInfo_negotiator')}]];
        var prefix = ctx + "system/incomeplayinfo";

        function total(){
        	$.ajax({
	            url: prefix + "/total",
	            data: $('#formId').serialize(),
	            type: "post",
	            success: function(result) {
	            	if (result.code == 200) {
	            		var ss = result.msg.split("#");
	            		$("#income").html(ss[0]); //JQuery
	            		$("#play").html(ss[1]); //JQuery
	            		$("#balance").html(ss[2]); //JQuery
	            	} else {
	            		alert(result.msg);
	            	}
	            }
	        })
        }
        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "收支记录",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'produceId', 
                    title: '主键id',
                    visible: false
                },
                {
                    field: 'produceName', 
                    title: '物品名称'
                },
                {
                    field: 'playType', 
                    title: '支付种类',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(playTypeDatas, value);
                    }
                },
                {
                    field: 'produceType', 
                    title: '物品种类',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(produceTypeDatas, value);
                    }
                },
                {
                    field: 'producePrice', 
                    title: '物品价格'
                },
                {
                    field: 'producePalydate', 
                    title: '交易时间'
                },
                {
                    field: 'produceDesc', 
                    title: '物品描述'
                },
                {
                    field: 'produceNegotiator', 
                    title: '交易人',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(produceNegotiatorDatas, value);
                    }
                },
                {
                    field: 'remark', 
                    title: '备注'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.produceId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.produceId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>